<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of AddUser
 *
 *          @author ghazy
 */

class Application_Form_AddUser extends Zend_Form {

    public function  init() {

        //***here will set action and method
        $this->setMethod('post');


        $name = new Zend_Form_Element_Text('name');
        $name->setLabel('Name')
             ->setRequired(true)
             ->addFilter(new Zend_Filter_HtmlEntities())
             ->addFilter(new Zend_Filter_StringTrim())
             //->addValidator('Alpha',false,array('allowWhiteSpace' => false))
             ->addValidator('NotEmpty',true);

        $mail = new Zend_Form_Element_Text('mail');
        $mail->setLabel('Email')
             ->setRequired(true)
             ->addFilter(new Zend_Filter_HtmlEntities())
             ->addValidator(new Zend_Validate_EmailAddress())
             ->addValidator('NotEmpty',true);

        $password = new Zend_Form_Element_Password('password');
        $password->setLabel('password')
             ->setRequired(true)
             ->addFilter(new Zend_Filter_HtmlEntities())  
             //->addValidator('Alpha',false,array('allowWhiteSpace' => false))
             ->addValidator('NotEmpty',true);


        $verify_pass = new Zend_Form_Element_Password('verify');
        $verify_pass->setLabel('re-type password')
             ->setRequired(true)
             ->addFilter(new Zend_Filter_HtmlEntities())
             //->addValidator('Alpha',false,array('allowWhiteSpace' => false))
             ->addValidator('NotEmpty',true);

        
        //*****************doctrine ---> dropdownlist***************

        $role = new Zend_Form_Element_Select('role');
        $role->setLabel('Roles');
        $q = Doctrine_Query::create()->from('TblRole r');
        $q_roles = $q->execute();
        
        foreach($q_roles as $q_r)
        {
            $array[$q_r['id']] = $q_r->name;
        }

        $role->setMultiOptions($array);
        $role->setRequired(true);




        $status = new Zend_Form_Element_Select('status');
        $status->setLabel('User Status')
             ->setMultiOptions(array(
                'active' => 'active',
                'inactive' => 'inactive',
                 'blocked' => 'blocked'
             ))
             ->setRequired(true);


        //--->>>> date has to be changed <<<<---------//
        $date = new Zend_Form_Element_Text('date');
        $date->setLabel('expire_date')
             ->setRequired(true)
             ->addFilter(new Zend_Filter_HtmlEntities())
             ->addFilter(new Zend_Filter_StringTrim())
             ->addValidator('NotEmpty',true);
             //->setAttrib('class','d');


        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Add User');


        $reset = new Zend_Form_Element_Reset('reset');
        $reset->setLabel('Reset');


        $this->addElement($name)
             ->addElement($mail)
             ->addElement($password)
             ->addElement($verify_pass)
             ->addElement($role)
             ->addElement($status)             
             ->addElement($date)
             ->addElement($reset)
             ->addElement($submit);

    }
}
?>
